package com.xl.controller;

import com.springmvc.anotation.AutoWired;
import com.springmvc.anotation.Controller;
import com.springmvc.anotation.RequestMapping;
import com.springmvc.anotation.RequestParam;
import com.xl.pojo.User;
import com.xl.service.UserService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@Controller
public class UserController {
    @AutoWired
    UserService userService;

    @RequestMapping("/user")
    public void findUsers(HttpServletRequest request, HttpServletResponse response, @RequestParam("name") String name) {
        response.setContentType("text/html;charset=utf-8");

        List<User> users = userService.findUsers(name);
        try {
            PrintWriter out = response.getWriter();
            out.print("<h1>SpringMvc控制器" + name + "</h1>");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
